import React, { lazy } from 'react'
import type { RouteObject } from 'react-router-dom'
import { Navigate } from 'react-router-dom'

const Discover = lazy(() => import('../views/discover'))
const Mine = lazy(() => import('../views/mine'))
const Focus = lazy(() => import('../views/focus'))
const Download = lazy(() => import('../views/download'))

// Discover 二级路由：
const Racommend = lazy(() => import('../views/discover/childViews/recommend/index'))
const Ranking = lazy(() => import('../views/discover/childViews/ranking/index'))
const Songs = lazy(() => import('../views/discover/childViews/songs/index'))
const Djradio = lazy(() => import('../views/discover/childViews/djradio/index'))
const Artist = lazy(() => import('../views/discover/childViews/artist/index'))
const Album = lazy(() => import('../views/discover/childViews/album/index'))

const routes: RouteObject[] = [
	{ path: '/', element: <Navigate to="/discover" /> },
	{
		path: '/discover',
		element: <Discover />,
		children: [
			{
				path: '/discover',
				element: <Navigate to="/discover/recommend" />
			},
			{
				path: '/discover/recommend',
				element: <Racommend />
			},
			{
				path: '/discover/ranking',
				element: <Ranking />
			},
			{
				path: '/discover/songs',
				element: <Songs />
			},
			{
				path: '/discover/djradio',
				element: <Djradio />
			},
			{
				path: '/discover/artist',
				element: <Artist />
			},
			{
				path: '/discover/album',
				element: <Album />
			}
		]
	},
	{ path: '/mine', element: <Mine />, children: [] },
	{ path: '/focus', element: <Focus />, children: [] },
	{ path: '/download', element: <Download />, children: [] }
]

export default routes
